package com.java.dormitorymanager.mvc.controller;

import com.java.dormitorymanager.mvc.handler.DormHandler;
import com.java.dormitorymanager.mvc.handler.ManagerHandler;
import com.java.dormitorymanager.mvc.handler.StudentHandler;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @program: DormitoryManager
 * @description: 总控
 * @author: ShuangChenYue
 * @create: 2021-05-14 17:36
 **/
@WebServlet(value = "*.do")
public class ControllerServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        ManagerHandler managerHandler = new ManagerHandler();
        StudentHandler studentHandler = new StudentHandler();
        DormHandler dormHandler = new DormHandler();
        String servletPath = req.getServletPath();
        servletPath = servletPath.substring(0,servletPath.lastIndexOf("."));
        if ("/mvc/managerLogin".equals(servletPath))
        {
            managerHandler.managerLogin(req,resp);
        }else if ("/mvc/managerRegister".equals(servletPath))
        {
            managerHandler.managerRegister(req,resp);
        }else if ("/mvc/toUpdateSMDetail".equals(servletPath))
        {
            managerHandler.toUpdateSMDetail(req,resp);
        }else  if ("/mvc/updateSMDetail".equals(servletPath))
        {
            managerHandler.updateSMDetail(req,resp);
        }else if ("/mvc/queryAllSMBeforeViewSMDetailAgain".equals(servletPath))
        {
            managerHandler.queryAllSMBeforeViewSMDetailAgain(req,resp);
        }else if ("/mvc/ManageCommonManager".equals(servletPath))
        {
            managerHandler.manageCommonManager(req,resp);
        }else if ("/mvc/deleteCommonManagerById".equals(servletPath))
        {
            managerHandler.deleteCommonManagerById(req, resp);
        }else if ("/mvc/commonManagerListAfterDelete".equals(servletPath))
        {
            managerHandler.commonManagerListAfterDelete(req, resp);
        }else if ("/mvc/toUpdateCMDetail".equals(servletPath))
        {
            managerHandler.toUpdateCMDetail(req, resp);
        }else if ("/mvc/updateCMDetail".equals(servletPath))
        {
            managerHandler.updateCMDetail(req, resp);
        }else if ("/mvc/addCommonManager".equals(servletPath))
        {
            managerHandler.addCommonManager(req, resp);
        }else if ("/mvc/showCMDetailAgain".equals(servletPath))
        {
            managerHandler.showCMDetailAgain(req, resp);
        }else if ("/mvc/searchCMByName".equals(servletPath))
        {
            managerHandler.searchCMByName(req, resp);
        }else if ("/mvc/bannedCommonManager".equals(servletPath))
        {
            managerHandler.bannedCommonManager(req, resp);
        }else if ("/mvc/deleteBannedManagerById".equals(servletPath))
        {
            managerHandler.deleteBannedManagerById(req, resp);
        }else if ("/mvc/openBannedManagerById".equals(servletPath))
        {
            managerHandler.openBannedManagerById(req, resp);
        }else if ("/mvc/studentLogin".equals(servletPath))
        {
            studentHandler.studentLogin(req,resp);
        }else if ("/mvc/studentRegister".equals(servletPath))
        {
            studentHandler.studentRegister(req, resp);
        }else if ("/mvc/ManageStudentManager".equals(servletPath))
        {
            studentHandler.manageStudentManager(req, resp);
        }else if ("/mvc/searchStudentByName".equals(servletPath))
        {
            studentHandler.searchStudentByName(req, resp);
        }else if ("/mvc/showStudentDetail".equals(servletPath))
        {
            studentHandler.showStudentDetail(req, resp);
        }else if ("/mvc/deleteStudent".equals(servletPath))
        {
            studentHandler.deleteStudent(req, resp);
        }else if ("/mvc/addStudent".equals(servletPath))
        {
            studentHandler.addStudent(req, resp);
        }else if ("/mvc/toUpdateStudent".equals(servletPath))
        {
            studentHandler.toUpdateStudent(req, resp);
        }else if ("/mvc/updateStudent".equals(servletPath))
        {
            studentHandler.updateStudent(req, resp);
        }else if ("/mvc/ManageDorm".equals(servletPath))
        {
            dormHandler.manageDorm(req, resp);
        }else if ("/mvc/addDorm".equals(servletPath))
        {
            dormHandler.addDorm(req, resp);
        }else if ("/mvc/toAddMSToDorm".equals(servletPath))
        {
            dormHandler.toAddMSToDorm(req, resp);
        }else if ("/mvc/addMSToDorm".equals(servletPath))
        {
            dormHandler.addMSToDorm(req,resp);
        }else if ("/mvc/showDormDetail".equals(servletPath))
        {
            dormHandler.showDormDetail(req, resp);
        }else if ("/mvc/deleteMSFromDorm".equals(servletPath))
        {
            dormHandler.deleteMSFromDorm(req, resp);
        }else if ("/mvc/addScoreToDorm".equals(servletPath))
        {
            dormHandler.addScoreToDorm(req, resp);
        }else  if ("/mvc/updateScoreAfterAdd".equals(servletPath))
        {
            dormHandler.updateScoreAfterAdd(req, resp);
        }else if ("/mvc/deleteDormByDornum".equals(servletPath))
        {
            dormHandler.deleteDormByDornum(req, resp);
        }else if ("/mvc/toUpdateDormInfo".equals(servletPath))
        {
            dormHandler.toUpdateDormInfo(req, resp);
        }else if ("/mvc/afterUpdateDormInfo".equals(servletPath))
        {
            dormHandler.afterUpdateDormInfo(req, resp);
        }else if ("/mvc/showAllManDormUpWithScore".equals(servletPath))
        {
            dormHandler.showAllManDormUpWithScore(req, resp);
        }else if ("/mvc/showAllManDormDownWithScore".equals(servletPath))
        {
            dormHandler.showAllManDormDownWithScore(req, resp);
        }else if ("/mvc/showAllManDormDefault".equals(servletPath))
        {
            dormHandler.showAllManDormDefault(req, resp);
        }else if ("/mvc/toAddWSToDorm".equals(servletPath))
        {
            dormHandler.toAddWSToDorm(req, resp);
        }else if ("/mvc/addFSToDorm".equals(servletPath))
        {
            dormHandler.addFSToDorm(req, resp);
        }else if ("/mvc/showAllWomanDormUpWithScore".equals(servletPath))
        {
            dormHandler.showAllWomanDormUpWithScore(req, resp);
        }else if ("/mvc/showAllWomanDormDownWithScore".equals(servletPath))
        {
            dormHandler.showAllWomanDormDownWithScore(req, resp);
        }else if ("/mvc/showAllWomanDormDefault".equals(servletPath))
        {
            dormHandler.showAllWomanDormDefault(req, resp);
        }else if ("/mvc/findDormByDornum".equals(servletPath))
        {
            dormHandler.findDormByDornum(req,resp);
        }else if ("/mvc/toUpdateDMDetail".equals(servletPath))
        {
            managerHandler.toUpdateDMDetail(req, resp);
        }else if ("/mvc/updateDMDetail".equals(servletPath))
        {
            managerHandler.updateDMDetail(req, resp);
        }
    }
}
